package com.pingan.internal.point.shopping.controller.response;

import com.pingan.internal.point.shopping.common.msg.ErrorMessage;

public class ResponseData<T> {

    private String code;
    private String message;
    private T Data;

    public ResponseData() {
    }
    public ResponseData(String code, String message, T data) {
        this.code = code;
        this.message = message;
        Data = data;
    }

    public static <T> ResponseData success(T data){
            ResponseData<T> rd = new ResponseData<>();
            rd.setCode(ErrorMessage.SUCCESS.getCode());
            rd.setMessage(ErrorMessage.SUCCESS.getMessage());
            rd.setData(data);
            return rd;
    }

    public static <T> ResponseData success(){
        ResponseData<T> rd = new ResponseData<>();
        rd.setCode(ErrorMessage.SUCCESS.getCode());
        rd.setMessage(ErrorMessage.SUCCESS.getMessage());
        return rd;
    }

    public static <T> ResponseData error(ErrorMessage error){
        ResponseData<T> rd = new ResponseData<>();
        rd.setCode(error.getCode());
        rd.setMessage(error.getMessage());
        return rd;
    }

    public static <T> ResponseData error(String code,String message){
        ResponseData<T> rd = new ResponseData<>();
        rd.setCode(code);
        rd.setMessage(message);
        return rd;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getData() {
        return Data;
    }

    public void setData(T data) {
        Data = data;
    }
}
